<template>
    <view class="main">
        <scroll-view class="scrollview" :scroll-y="true" :style="{ height: height + 'px' }"
            @scrolltolower="orderScrolltolower">
            <view style="height: 30rpx "></view>
            <order :data="item" v-for="item in msg" :key="item.id" @closeS="closeShow"
                @_getRecoverList="_getRecoverList()" @myEven="getlist" />
            <u-loadmore :status="status" :load-text="loadText" />
            <view class="scrollview-height"></view>
        </scroll-view>
    </view>
</template>

<script>
    import order from './hang.vue';
    export default {
        components: {
            order
        },
        data() {
            return {
                height: 0,
                params: {
                    page: 1,
                    limit: 20,
                    status: 1
                },
                msg: [],
                status: 'loading',
                loadText: {
                    loadmore: '上拉加载更多',
                    loading: '加载中...',
                    nomore: '没有更多数据了'
                },
            };
        },
        onShow() {
            this._getRecoverList();
        },
        mounted() {
            const query = uni.createSelectorQuery();
            query
                .in(this)
                .select('.main')
                .boundingClientRect();
            query.exec(res => {
                this.height = uni.getSystemInfoSync().windowHeight - res[0].top - uni.upx2px(160);
            });
            this._getRecoverList();
        },
        methods: {
            // 重新获取列表数据
            getlist() {
                this._getRecoverList();
                console.log('---------')
            },
            // 显示弹窗，隐藏TabBar
            closeShow(data) {
                this.$emit('showtabbar');
                this.dataItem = data;
                this.isShow = true;
            },
            orderScrolltolower() {
                this.params.page++;
                this._getRecoverList();
            },
            _getRecoverList() {
                let params = {};
                this.status = 'loading';
                if (this.params.status == null) {
                    params = {
                        page: this.params.page,
                        limit: this.params.limit
                    };
                } else {
                    params = this.params;
                }
                this.$u.api
                    .getHangList(params)
                    .then(res => {
                        // this.msg = res.list;z
                        if (this.params.page == 1) {
                            this.status = 'nomore';
                            this.msg = res.list;
                        } else {
                            if (res.list <= 0) {
                                this.status = 'nomore';
                                this.params.page = this.olPage;
                                return;
                            }
                            this.olPage = this.params.page;
                            this.msg = this.msg.concat(res.list);
                        }
                    })
                    .catch(err => {
                        console.log(err)
                    });
            }
        }
    };
</script>

<style></style>